package cn.bugstack.springframework.util;

public class ClassUtils {

    public static ClassLoader getDefaultClassLoader() {
        ClassLoader cl = null;
        try {
            //先通过当前线程获取类加载器
            cl = Thread.currentThread().getContextClassLoader();
        }
        catch (Throwable ex) {
            // Cannot access thread context ClassLoader - falling back to system class loader...
        }
        if (cl == null) {
            // No thread context class loader -> use class loader of this class.
            //当线程中没有这个类加载器的时候去拿class的类加载器
            cl = ClassUtils.class.getClassLoader();
        }
        return cl;
    }

}
